<?php
namespace x\my;
use Yansongda\Pay\Pay as Pays;
class Pay
{
    /**
     * 发起支付
     * @param  string $driver     [驱动]
     * @param  string $gateway    [网关]
     * @param  [type] $order_no   [订单编号]
     * @param  [type] $money      [金额]
     * @param  string $subject    [消费标题]
     * @param  string $return_url [同步返回地址]
     * @param  string $notify_url [异步通知地址]
     * @return [type]             [description]
     */
    public static function send($driver='alipay',$gateway='web',$order_no, $money, $subject='消费', $conf=[]){
        #配置
        $config = self::config();
        $config[$driver] = array_merge($config[$driver],$conf);
        #参数
        $param = [
            'out_trade_no' => $order_no,
            'total_amount' => $money,
            'subject'      => $subject,
        ];
        $pay = new Pays($config);
        return $pay->driver($driver)->gateway($gateway)->pay($param);
    }

    //验证
    public static function check(){

    }

    /**
     * 支付配置
     * @return [type] [description]
     */
    public static function config(){
        $config = [
            #支付宝
            'alipay' => [
                'app_id'         =>  c('api.alipay_partner'),
                'notify_url'     =>  c('api.alipay_notify_url'),
                'return_url'     =>  c('api.alipay_return_url'),
                'ali_public_key' =>  c('api.alipay_key'),
                // 加密方式： **RSA2**
                'private_key' => c('api.alipay_private_key'),
            ],
        ];
        return $config;
    }
}
